/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('nbf', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AscpAppointOrderCancelledErpSpiRequest {
  appointOrderCode?: string(name='appointOrderCode', description='预约单号'),
  extFields?: string(name='extFields', description='扩展字段'),
  fulfilmentOrderCode?: string(name='fulfilmentOrderCode', description='履行单号'),
  outBusinessOrderCode?: string(name='outBusinessOrderCode', description='关联业务单号'),
  outOrderCode?: string(name='outOrderCode', description='待预约单据编号'),
  reason?: string(name='reason', description='取消原因'),
  supplierId?: long(name='supplierId', description='供应商ID'),
  routeSupplierId?: long(name='routeSupplierId', description='供应商ID，路由专用'),
}

model AscpAppointOrderCancelledErpSpiResponseBody = {
  errorCode?: string(name='errorCode', description='错误编码，失败情况下返回'),
  errorMsg?: string(name='errorMsg', description='错误描述，失败情况下返回'),
  success?: boolean(name='success', description='请求是否成功'),
}

model AscpAppointOrderCancelledErpSpiResponse = {
  headers: map[string]string(name='headers'),
  body: AscpAppointOrderCancelledErpSpiResponseBody(name='body'),
}

async function ascpAppointOrderCancelledErpSpi(request: AscpAppointOrderCancelledErpSpiRequest): AscpAppointOrderCancelledErpSpiResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return ascpAppointOrderCancelledErpSpiWithOptions(request, headers, runtime);
}

async function ascpAppointOrderCancelledErpSpiWithOptions(request: AscpAppointOrderCancelledErpSpiRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AscpAppointOrderCancelledErpSpiResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.routeSupplierId)) {
    query['routeSupplierId'] = request.routeSupplierId;
  }

  var body : map[string]any= {};
  if (!Util.isUnset(request.appointOrderCode)) {
    body['appointOrderCode'] = request.appointOrderCode;
  }
  if (!Util.isUnset(request.extFields)) {
    body['extFields'] = request.extFields;
  }
  if (!Util.isUnset(request.fulfilmentOrderCode)) {
    body['fulfilmentOrderCode'] = request.fulfilmentOrderCode;
  }
  if (!Util.isUnset(request.outBusinessOrderCode)) {
    body['outBusinessOrderCode'] = request.outBusinessOrderCode;
  }
  if (!Util.isUnset(request.outOrderCode)) {
    body['outOrderCode'] = request.outOrderCode;
  }
  if (!Util.isUnset(request.reason)) {
    body['reason'] = request.reason;
  }
  if (!Util.isUnset(request.supplierId)) {
    body['supplierId'] = request.supplierId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AscpAppointOrderCancelledErpSpi',
    version = '2021-07-06_16-58-49-384',
    protocol = 'HTTP',
    pathname = `/ascpAppointOrderCancelledErpSpi`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model AscpAppointOrderCreatedErpSpiRequest {
  appointOrderCode?: string(name='appointOrderCode', description='预约单号'),
  entityCode?: string(name='entityCode', description='仓库编码（物理仓）'),
  entityName?: string(name='entityName', description='仓库名称（物理仓）'),
  extFields?: string(name='extFields', description='附加信息'),
  gmtCreate?: string(name='gmtCreate', description='预约单创建时间'),
  inboundType?: string(name='inboundType', description='出入库方式'),
  items?: [ 
    {
      box?: int32(name='box', description='总箱数'),
      brandName?: string(name='brandName', description='品牌名称'),
      categoryName?: string(name='categoryName', description='商品类目'),
      extFields?: string(name='extFields', description='附加信息'),
      goodsBarCode?: string(name='goodsBarCode', description='条形码'),
      itemId?: long(name='itemId', description='商品ID'),
      packageModel?: string(name='packageModel', description='存储类型'),
      pcs?: int32(name='pcs', description='箱规'),
      planNum?: int32(name='planNum', description='总件数'),
      scItemId?: long(name='scItemId', description='货品ID'),
      scItemName?: string(name='scItemName', description='货品名称'),
      skuId?: long(name='skuId', description='SKUID'),
      unit?: string(name='unit', description='计量单位'),
      volume?: float(name='volume', description='体积（立方毫米）'),
      weight?: float(name='weight', description='重量（克）'),
    }
  ](name='items', description='明细列表'),
  memberId?: long(name='memberId', description='二级供应商编码'),
  orderType?: int32(name='orderType', description='预约单类型'),
  outBusinessOrderCode?: string(name='outBusinessOrderCode', description='关联业务单号'),
  outOrderCode?: string(name='outOrderCode', description='待预约单据编号'),
  realSupplierNick?: string(name='realSupplierNick', description='供应商名称'),
  relationCode?: string(name='relationCode', description='仓库编码（逻辑仓）'),
  relationName?: string(name='relationName', description='仓库名称（逻辑仓）'),
  supplierId?: long(name='supplierId', description='供应商ID'),
  routeSupplierId?: long(name='routeSupplierId', description='供应商ID，路由专用'),
}

model AscpAppointOrderCreatedErpSpiResponseBody = {
  errorCode?: string(name='errorCode', description='错误编码，失败情况下返回'),
  errorMsg?: string(name='errorMsg', description='错误描述，失败情况下返回'),
  success?: boolean(name='success', description='请求是否成功'),
}

model AscpAppointOrderCreatedErpSpiResponse = {
  headers: map[string]string(name='headers'),
  body: AscpAppointOrderCreatedErpSpiResponseBody(name='body'),
}

async function ascpAppointOrderCreatedErpSpi(request: AscpAppointOrderCreatedErpSpiRequest): AscpAppointOrderCreatedErpSpiResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return ascpAppointOrderCreatedErpSpiWithOptions(request, headers, runtime);
}

async function ascpAppointOrderCreatedErpSpiWithOptions(request: AscpAppointOrderCreatedErpSpiRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AscpAppointOrderCreatedErpSpiResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.routeSupplierId)) {
    query['routeSupplierId'] = request.routeSupplierId;
  }

  var body : map[string]any= {};
  if (!Util.isUnset(request.appointOrderCode)) {
    body['appointOrderCode'] = request.appointOrderCode;
  }
  if (!Util.isUnset(request.entityCode)) {
    body['entityCode'] = request.entityCode;
  }
  if (!Util.isUnset(request.entityName)) {
    body['entityName'] = request.entityName;
  }
  if (!Util.isUnset(request.extFields)) {
    body['extFields'] = request.extFields;
  }
  if (!Util.isUnset(request.gmtCreate)) {
    body['gmtCreate'] = request.gmtCreate;
  }
  if (!Util.isUnset(request.inboundType)) {
    body['inboundType'] = request.inboundType;
  }
  if (!Util.isUnset(request.items)) {
    body['items'] = request.items;
  }
  if (!Util.isUnset(request.memberId)) {
    body['memberId'] = request.memberId;
  }
  if (!Util.isUnset(request.orderType)) {
    body['orderType'] = request.orderType;
  }
  if (!Util.isUnset(request.outBusinessOrderCode)) {
    body['outBusinessOrderCode'] = request.outBusinessOrderCode;
  }
  if (!Util.isUnset(request.outOrderCode)) {
    body['outOrderCode'] = request.outOrderCode;
  }
  if (!Util.isUnset(request.realSupplierNick)) {
    body['realSupplierNick'] = request.realSupplierNick;
  }
  if (!Util.isUnset(request.relationCode)) {
    body['relationCode'] = request.relationCode;
  }
  if (!Util.isUnset(request.relationName)) {
    body['relationName'] = request.relationName;
  }
  if (!Util.isUnset(request.supplierId)) {
    body['supplierId'] = request.supplierId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AscpAppointOrderCreatedErpSpi',
    version = '2021-07-06_16-58-49-384',
    protocol = 'HTTP',
    pathname = `/ascpAppointOrderCreatedErpSpi`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model AscpAppointOrderDoFinishedErpSpiRequest {
  appointDate?: string(name='appointDate', description='预约日期（新）'),
  appointOrderCode?: string(name='appointOrderCode', description='预约单号'),
  appointType?: string(name='appointType', description='预约类型'),
  appointWave?: int32(name='appointWave', description='预约波次（新）'),
  extFields?: string(name='extFields', description='扩展信息'),
  fulfilmentOrderCode?: string(name='fulfilmentOrderCode', description='履行单号'),
  originalAppointDate?: string(name='originalAppointDate', description='预约日期(旧)'),
  originalAppointWave?: int32(name='originalAppointWave', description='预约波次(旧)'),
  outBusinessOrderCode?: string(name='outBusinessOrderCode', description='关联业务单号'),
  outOrderCode?: string(name='outOrderCode', description='待预约单据编号'),
  reason?: string(name='reason', description='改约原因'),
  supplierId?: long(name='supplierId', description='供应商ID'),
  warehouseAddress?: string(name='warehouseAddress', description='库位地址'),
  warehouseType?: string(name='warehouseType', description='库位类型'),
  routeSupplierId?: long(name='routeSupplierId', description='供应商ID，路由专用'),
}

model AscpAppointOrderDoFinishedErpSpiResponseBody = {
  errorCode?: string(name='errorCode', description='错误编码，失败情况下返回'),
  errorMsg?: string(name='errorMsg', description='错误描述，失败情况下返回'),
  success?: boolean(name='success', description='请求是否成功'),
}

model AscpAppointOrderDoFinishedErpSpiResponse = {
  headers: map[string]string(name='headers'),
  body: AscpAppointOrderDoFinishedErpSpiResponseBody(name='body'),
}

async function ascpAppointOrderDoFinishedErpSpi(request: AscpAppointOrderDoFinishedErpSpiRequest): AscpAppointOrderDoFinishedErpSpiResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return ascpAppointOrderDoFinishedErpSpiWithOptions(request, headers, runtime);
}

async function ascpAppointOrderDoFinishedErpSpiWithOptions(request: AscpAppointOrderDoFinishedErpSpiRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AscpAppointOrderDoFinishedErpSpiResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.routeSupplierId)) {
    query['routeSupplierId'] = request.routeSupplierId;
  }

  var body : map[string]any= {};
  if (!Util.isUnset(request.appointDate)) {
    body['appointDate'] = request.appointDate;
  }
  if (!Util.isUnset(request.appointOrderCode)) {
    body['appointOrderCode'] = request.appointOrderCode;
  }
  if (!Util.isUnset(request.appointType)) {
    body['appointType'] = request.appointType;
  }
  if (!Util.isUnset(request.appointWave)) {
    body['appointWave'] = request.appointWave;
  }
  if (!Util.isUnset(request.extFields)) {
    body['extFields'] = request.extFields;
  }
  if (!Util.isUnset(request.fulfilmentOrderCode)) {
    body['fulfilmentOrderCode'] = request.fulfilmentOrderCode;
  }
  if (!Util.isUnset(request.originalAppointDate)) {
    body['originalAppointDate'] = request.originalAppointDate;
  }
  if (!Util.isUnset(request.originalAppointWave)) {
    body['originalAppointWave'] = request.originalAppointWave;
  }
  if (!Util.isUnset(request.outBusinessOrderCode)) {
    body['outBusinessOrderCode'] = request.outBusinessOrderCode;
  }
  if (!Util.isUnset(request.outOrderCode)) {
    body['outOrderCode'] = request.outOrderCode;
  }
  if (!Util.isUnset(request.reason)) {
    body['reason'] = request.reason;
  }
  if (!Util.isUnset(request.supplierId)) {
    body['supplierId'] = request.supplierId;
  }
  if (!Util.isUnset(request.warehouseAddress)) {
    body['warehouseAddress'] = request.warehouseAddress;
  }
  if (!Util.isUnset(request.warehouseType)) {
    body['warehouseType'] = request.warehouseType;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AscpAppointOrderDoFinishedErpSpi',
    version = '2021-07-06_16-58-49-384',
    protocol = 'HTTPS',
    pathname = `/ascpAppointOrderDoFinishedErpSpi`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

